package com.imist.demo;

import com.imist.jdbcutil.JDBCUtil;
import org.junit.Test;

import java.sql.Connection;
import java.sql.Statement;

public class JDBCDemo3 {

    @Test
    public void save(){
        Connection conn = null;
        Statement statement = null;
        try {
            //获得连接
            conn = JDBCUtil.getConnection();
            //创建执行SQL语句的对象
            statement = conn.createStatement();
            //编写SQL语句
            String sql = "INSERT user(username,password,name) VALUES ('工具测试','123456','测试')";
            int i = statement.executeUpdate(sql);
            if (i > 0){
                System.out.println("保存成功");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }finally {
            JDBCUtil.release(conn,statement);
        }
    }
}
